package com.atguigu.redisdemo;

import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

public class MyRedisPool {
    public static void main(String[] args) {
        //1.配置线程池
        JedisPoolConfig config = new JedisPoolConfig();
            //1.1线程池中的最大空闲连接数
        config.setMaxIdle(5);
            //1.2线程池中线程总数
        config.setMaxTotal(10);
            //1.3线程池中最小空闲连接数
        config.setMinIdle(2);
            //1.4连接线程池
        JedisPool jedisPool = new JedisPool(config, "hadoop102", 6379);
        //2.获取jedis连接对象
        Jedis jedis = jedisPool.getResource();
        System.out.println(jedis.ping());
        //3.归还线程
        jedis.close();
    }
}
